package com.ikun.service.impl;

import com.ikun.mapper.TbTaskMapper;
import com.ikun.mapper.TbUserPrizeMapper;
import com.ikun.pojo.Result;
import com.ikun.pojo.TbUserPrize;
import com.ikun.service.UserPrizeService;
import com.ikun.util.TimeUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserPrizeServiceImpl implements UserPrizeService {

    @Autowired
    TbUserPrizeMapper tbUserPrizeMapper;

    //兑换奖品
    @Override
    public int cashRewards(Long userId, Long prizeId) {
        String time = TimeUtil.getNowTime();
        System.out.println(userId+":"+prizeId);
        int count = tbUserPrizeMapper.cashRewards(userId,prizeId,time);
        return count;
    }
    @Autowired
    TbUserPrizeMapper mapper;
    @Override
    public List<TbUserPrize> selectmsg() {
        List<TbUserPrize> list=mapper.selectmsg();
        if (list!=null){
            System.out.println("集合不为空");
            return  list;
        }else{
            System.out.print("查询错误");
        }
        return list;
    }

    @Override
    public List<TbUserPrize> selectprize() {
        List<TbUserPrize> list=mapper.selectprize();
        if (list!=null){
            System.out.println("集合不为空");
            return  list;
        }else{
            System.out.print("查询错误");
        }
        return list;
    }

    @Override
    public int check(int id, String finishtime) {
        int count=mapper.check(id,finishtime);
        System.out.println(count);
        if (count>0){
            System.out.println("有数据");
            return  count;
        }else{
            System.out.print("查询错误");
        }
        return count;
    }

    @Override
    public int delprize(int id) {
        int count=mapper.delprize(id);
        if (count>0){
            System.out.println("删除成功");
        }else {
            System.out.println("删除失败");
        }
        return count;
    }
}
